package hot_100;

public class 最大子数组和 {
    public static void main(String[] args) {
    }

    public int maxSubArray(int[] nums) {
        int ans = -0x3f3f3f3f;
        int sum = 0;
        for (int i = 0; i < nums.length; i++) {
            sum = Math.max(sum, 0) + nums[i];
            ans = Math.max(sum, ans);
        }
        return ans;
    }
}
